package cn.zhoujing.resource.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @author zhoujing
 * @createTime 2023/11/26 - 13:00
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {


    @GetMapping(value = "/user")
    public String user(){
        return "user";
    }

    @GetMapping(value = "admin")
    @PreAuthorize("hasAnyAuthority('admin')")
    public String admin(){
        return "admin";
    }

    @GetMapping(value = "/info")
    public Principal info(Principal principal){
        return principal;
    }

}
